package com.hky.cli.command;

import cn.hutool.core.bean.BeanUtil;
import com.hky.generator.MainGenerator;
import com.hky.model.MainTemplateConfig;
import lombok.Data;
import picocli.CommandLine.Option;
import picocli.CommandLine.Command;

import java.util.concurrent.Callable;
@Data
@Command(name = "generate", description = "生成代码", mixinStandardHelpOptions = true)
public class GenerateCommand implements Callable<Integer> {

    /**
     * 作者
     */
    @Option(names = {"-a", "--author"}, defaultValue = "作者名称", arity = "0..1", interactive = true, echo = true)
    private String author = "hky";

    /**
     * 输出信息
     */
    @Option(names = {"-o", "--outputText"}, defaultValue = "输出文本", arity = "0..1", interactive = true, echo = true)
    private String outputText = "sum=";

    /**
     * 是否循环
     */
    @Option(names = {"-l", "--loop"}, defaultValue = "是否循环", arity = "0..1", interactive = true, echo = true)
    private boolean loop;

    @Override
    public Integer call() throws Exception {
        MainTemplateConfig mainTemplateConfig = new MainTemplateConfig();
        BeanUtil.copyProperties(this, mainTemplateConfig);
        System.out.println("配置信息：" + mainTemplateConfig);
        MainGenerator.doGenerate(mainTemplateConfig);
        return 0;
    }
}
